package com.sun.rabbitMQ.WorkQueues;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.rabbitmq.client.Delivery;
import com.sun.rabbitMQ.utils.FactoryUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Consumer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = FactoryUtils.getChannel();
        DeliverCallback callback = (consumerTag,message) ->{
            System.out.println("接收到的消息：" + new String(message.getBody()));
        };
        CancelCallback cancelCallback = (var1) ->{
            System.out.println("消息被取消");
        };
        System.out.println("C2 接收消息");
        channel.basicConsume(FactoryUtils.QUEUE_NAME,true,callback,cancelCallback);

    }
}
